﻿using System;

namespace LMCommonage.Configurations
{
    public class KDConfigurations
    {
        private static readonly int _group = (int)ConfigurationGroupSchema.KD标准配置;

        public enum KeyScheme
        {
            是否为测试环境 = 1,
            数据中心ID,
            管理员密码,
            数据库名称,
            目标成本报表获取成本计算单数据过滤方案ID
        }

        public const string ADMIN_ACCOUNT = "administrator";

        /// <summary>
        /// 人民币内码
        /// </summary>
        public const int CNY_ID = 1;

        public static bool IsTest(Func<string, string> sqlExecuter)
        {
            var sql = $@"select top 1 f_value
                from configurations
                where f_group = {_group}
                and f_key = {(int)KeyScheme.是否为测试环境};";
            var c = sqlExecuter(sql);
            var r = "1".Equals(c);
            return r;
        }

        public static string 目标成本报表获取成本计算单数据过滤方案(Func<string, string> sqlExecuter)
        {
            var sql = $@"select top 1 f_value
                from configurations
                where f_group = {_group}
                and f_key = {(int)KeyScheme.目标成本报表获取成本计算单数据过滤方案ID};";
            var c = sqlExecuter(sql);
            return c;
        }
    }
}
